<?php
/**
 * system.php
 *
 * $Id: system.php 139 2011-09-24 17:13:40Z alpha1130@gmail.com $
 */
 
class System extends OA_Controller
{
	/**
     * @name 备份管理
     * @desc 数据库备份管理，备份数据发送开关及发送目标邮箱地址的设置
     */
    public function backup_config_setup()
    {
    	$data = array();
    	$vars = $this->db
    		->where_in('key', array(
    			'backup_post_email_1', 
    			'backup_post_email_2', 
    			'backup_exec_rate'))
    		->get('sys_vars')
    		->result_array();
    	foreach($vars as $var)
    	{
    		$data[$var['key']] = $var['val'];
    	}
    	
    	$this->load->view('system_backup_setup', $data);
    }
    
    /**
     * @name 保存备份设置
     * @desc 保存数据库备份设置的参数
     * @method post
     */
    public function backup_config_save()
    {
    	list($data) = $this->check(array(
    		'backup_post_email_1' => FC_email('Email地址1'),
    		'backup_post_email_2' => FC_email('Email地址2'),
    		'backup_exec_freq' => FC_str('备份周期')->re('/^(1d|3d|1w)?$/')->required()
    	));
    	
    	foreach($data as $key => $val)
    	{
    		$this->db->update('sys_vars',
	    		array('val' => $val),
	    		array('key' => $key));
    	}
    	
    	$this->load->view('info', array(
    	    'message' => '备份设置成功'
    	));
    	
    }
}

/* End file of system.php */
/* Location: system.php */